<?php
namespace Admin\Controller;
use Think\Controller;
class WaiterController extends CommonController {
	public function index()
	{
		$W=M("Waiter");
		$Warr=$W->group('type')->select();
		$array = array();
		foreach ($Warr as $key => $v) {
			$a=$W->where('type='.$v['type'])->select();
			array_push($array, $a);
				  
		}
		$this->list=$array;
		$this->display();
	}
	//客服添加
	public function insert()
	{
		if (!empty($_POST)) {
		$name="Waiter";
		$this->_insert($name);
		}else{
		$this->display();
		}
	}
	//客服号码修改
	public function sort()
    {

    	// $this->_sort("Waiter");
    	$Site=D("Waiter");
    			C('TOKEN_ON',false);
            if ($Site->create()) {
                $list=$Site->save();
                if ($list!=false) {
                    $this->ajaxReturn('修改成功');
                    
                }else{
                    $this->ajaxReturn('修改失败');
                }
            }else{
                $this->ajaxReturn($Site->getError());
            }

    	
    }
    //客服删除
    public function delete()
    {
    	$name="Waiter";
    	$sid=I("post.sid");
    	$this->_foreverdelete($name,$sid);
    }

  // ----------------------------短信邮箱设置-----------------------------
  public function message()
  {
  	$M=M("Message");
  	$Marr=$M->select();
	$this->Marr=$Marr;
  	$this->display();

  }

  	//编辑
	public function edit()
	{
	 $name="Message";
		if (!empty($_POST)) {
			$this->_update($name);
		}else{
		  $this->_edit($name);
	  }
    }
}